﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using SmartSpace.Core;
using System.Collections;

namespace SsTool.Common
{
    /// <summary>
    /// Interaction logic for SelectRoleWindow.xaml
    /// </summary>
    public partial class SelectRoleWindow : Window
    {
        public List<Role> SelectedRoles { get; set; }

        public SelectRoleWindow()
        {
            InitializeComponent();
            this.Loaded += new RoutedEventHandler(SelectRoleWindow_Loaded);
        }

        void SelectRoleWindow_Loaded(object sender, RoutedEventArgs e)
        {
            ICoreService service = App.Get<ICoreService>();
            _ctlGrid.ItemsSource = service.GetRoles(0, 999);
        }

        private void _btnSubmit_Click(object sender, RoutedEventArgs e)
        {
            IList selectedRoles = _ctlGrid.SelectedItems as IList;

            SelectedRoles = new List<Role>();

            foreach (var item in selectedRoles)
            {
                SelectedRoles.Add((Role)item);
            }

            DialogResult = true;
        }

        private void _btnCancel_Click(object sender, RoutedEventArgs e)
        {
            DialogResult = false;
        }
    }
}
